package cn.gov.pbc.gd.credit.web.controller.notice;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.liu.jbase.PageListVo;
import com.liu.jbase.ResultVo;
import com.liu.jbase.controller.impl.BaseControllerImpl;
import com.liu.tools.NetHelper;

import cn.gov.pbc.gd.credit.core.service.notice.INoticeService;
import cn.gov.pbc.gd.credit.vo.notice.NoticeVo;
import cn.gov.pbc.gd.credit.vo.notice.ResNoticeVo;

@Controller
@RequestMapping("/notice")	
public class NoticeController extends BaseControllerImpl<ResNoticeVo, NoticeVo, INoticeService> {

	@Autowired
	private INoticeService noticeService;
	
	@RequestMapping("/main")
	public String total(NoticeVo vo, Model model, HttpServletRequest request){
		
		model.addAttribute("result", noticeService.totalForFristPage(vo, request));
		
		return "notice/main";
		
	} 
	
	@RequestMapping("/page/view")
	public String pageView(NoticeVo vo, Model model, HttpServletRequest request){
		
		model.addAttribute("result", noticeService.page(vo, new PageListVo<>(), request));
		model.addAttribute("noticeFlag", NetHelper.getReqParams(request, "noticeFlag", "0"));
		model.addAttribute("approveStatus", NetHelper.getReqParams(request, "approveStatus", "9"));
		model.addAttribute("status", NetHelper.getReqParams(request, "status", "9"));
		return "notice/page";
		
	} 
	
	@ResponseBody
	@RequestMapping("/approve")
	public ResultVo<ResNoticeVo> approve(NoticeVo vo, Model model, HttpServletRequest request){
		
		return noticeService.approve(vo, request);
		
	} 
	
	@ResponseBody
	@RequestMapping("/read")
	public ResultVo<ResNoticeVo> read(NoticeVo vo, Model model, HttpServletRequest request){
		
		return noticeService.read(vo, request);
		
	} 
}
